package com.service.atm;

import com.bpms.common.CommonUtil;
import com.bpms.common.VO;
import com.bpms.eai.PackTool;
import com.bpms.esb.IService;

public class Parse_atm_bill  extends PackTool implements IService {

	public VO exec(VO args) {
		byte[] body=(byte[])args.getObj("body");
		VO r=new VO();
		try{
			r.voType="ATM.Savebillimage";
			String DEVICENO=this.getField(body, body.length, "1001");  //设备号                     
			String NETNUM=this.getField(body, body.length, "1002");   //网点号               
			String BillDateTime=this.getField(body, body.length, "1003");    //日期时间                                                
			String TRANTYPE=this.getField(body, body.length, "1004");  //业务类型	01本行支票转账、02他行支票转账                              
			String ACCOUNTTYPE=this.getField(body, body.length, "1005");    //账号类型	1：ID卡 2：磁条卡  3：身份证                                         
			String CARDID=this.getField(body, body.length, "1006");    //账号	ID卡号或磁条卡号或身份证号        
			String PAYEEACCNO=this.getField(body, body.length, "1007");    //1007	收款人账号
			String DRAWEEACCNO=this.getField(body, body.length, "1008");    //1008	付款人账号
			String EXCHANGEBANKNO=this.getField(body, body.length, "1009");    //1009	交换行号
			String ISSUEDATE=this.getField(body, body.length, "1010");    //1010	出票日期
			String AMOUNT=this.getField(body, body.length, "1011");    //1011	金额
			String PASSWORD=this.getField(body, body.length, "1012");    //1012	支票密码
			String BILLNO=this.getField(body, body.length, "1013");    //1013	凭证号
			String photocount=this.getField(body, body.length, "1014");    //1014	影像张数
			
			
			//---------支持多张票据处理方法-----------------------------------------------------------------
			int ipagecount = Integer.parseInt(photocount);
			for(int i = 1;i <= ipagecount; i++){
				String photo = this.getField(body, body.length, String.format("T%03d", i));
				r.setAttr("photo"+ i, photo);
			}
			//--------------------------------------------------------------------------
			//String photo1 = this.getField(body, body.length, "T001");//第一张影像的base64编码
			//String photo2 = this.getField(body, body.length, "T002");//第二张影像的base64编码
					
			
			r.setAttr("DEVICENO",DEVICENO);
			r.setAttr("NETNUM",NETNUM);
			r.setAttr("BillDateTime",BillDateTime);
			r.setAttr("TRANTYPE",TRANTYPE);
			r.setAttr("ACCOUNTTYPE",ACCOUNTTYPE);
			r.setAttr("CARDID",CARDID);
			r.setAttr("PAYEEACCNO",PAYEEACCNO);
			r.setAttr("DRAWEEACCNO",DRAWEEACCNO);
			r.setAttr("EXCHANGEBANKNO",EXCHANGEBANKNO);
			r.setAttr("ISSUEDATE",ISSUEDATE);
			r.setAttr("AMOUNT",AMOUNT);
			r.setAttr("BILLNO",BILLNO);
			r.setAttr("PASSWORD",PASSWORD);
			
			r.setAttr("photocount",photocount);
			
			//r.setAttr("photo1",photo1);
			//r.setAttr("photo2",photo2);
			
			CommonUtil.debug("ATM.Parse_atm_bill parseBuffer");
			return r;
		}
		catch(Exception e)
		{
			CommonUtil.debug("Parse_atm_bill exception",e);
			return null;
		}
		
	}

}
